package com.example.lib_base_mvvm.baseMVVM.BaseView;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.example.lib_base_mvvm.baseMVVM.BaseViewModel.BaseViewModel;

public abstract class BaseFragmnet<VDB extends ViewDataBinding,VM extends BaseViewModel> extends Fragment {
    protected VDB dataBinding;
    protected VM viewModel;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.inflate(inflater,bindLayout(),container,false);
        viewModel = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
        return dataBinding.getRoot();
    }

    public abstract int bindLayout();
    public abstract void initView();
    public abstract void initData();
    public abstract Class<VM> getViewModel();
}
